package com.data.platform.core.enums;

import lombok.Getter;

/**
 * 响应码
 */
@Getter
public enum ResponseCode {

    SUCCESS(200,"成功"),

    // 参数相关的错误码：1开头
    TYPE_CONVERT_ERROR(1000,"类型转换异常"),
    USERNAME_NOT_FOUND(1001,"用户停用或用户不存在"),
    USERNAME_OR_PASSWORD_INVALID(1002, "无效的用户名和密码"),
    EMPTY_VERIFY_CODE(1003, "验证码为空"),
    INVALID_VERIFY_CODE(1004, "无效的验证码"),
    VERIFY_CODE_ERROR(1005, "验证码错误"),
    ROLE_NAME_NOT_FOUND(1006, "角色名不存在"),
    ROUTER_NOT_FOUND(1007, "路由存在"),
    KEY_NOT_GENERATE(1008, "公钥没生成"),
    KEY_EXPIRED(1009, "密钥失效"),
    DECRYPT_EXCEPTION(1010, "解密异常"),
    USERNAME_NOT_UNIQUE(1011, "用户名不唯一"),
    VALIDATION_ERROR(1012, "参数校验异常"),
    ROLE_NAME_NOT_UNIQUE(1013, "角色名不唯一"),
    MENU_NAME_NOT_UNIQUE(1014, "菜单名不唯一"),
    EMPTY_TOKEN(1015, "token为空"),
    PROJECT_NAME_NOT_UNIQUE(1016, "项目名不唯一"),
    JOB_NAME_NOT_UNIQUE(1017, "作业名不唯一"),

    // 权限相关的错误码：2开头
    INVALID_TOKEN(2001,"无效的token"),
    ACCESS_DENIED(2002,"没有权限访问该资源"),
    UNAUTHORIZED(2003, "尚未授权访问"),
    METHOD_NOT_ALLOWED(2004, "不支持此类型的方法"),
    UNAUTHORIZED_CLIENT_ID(2005, "clientId未授权"),
    INVALID_CLIENT(2006, "无效的客户端"),
    INVALID_GRANT(2007, "无效的授权类型"),
    INVALID_SCOPE(2008, "无效的scope"),
    INVALID_REQUEST(2009, "无效的请求"),
    REDIRECT_MISMATCH(2010, "redirect_uri未匹配"),
    UNSUPPORTED_GRANT_TYPE(2011, "不支持此授权类型"),
    UNSUPPORTED_RESPONSE_TYPE(2012, "不支持此类型的授权码"),

    // 系统相关的错误码：5开头
    SERVER_ERROR(5000,"服务器开小差，请稍后再试"),
    USER_STATUS_UPDATE_ERROR(5001, "用户状态更新失败"),
    PASSWORD_UPDATE_ERROR(5002, "密码更新失败"),
    USER_INSERT_ERROR(5003, "用户新增失败"),
    USER_UPDATE_ERROR(5004, "用户更新失败"),
    USER_DELETE_ERROR(5005, "用户删除失败"),
    ROLE_GET_ERROR(5006, "角色列表获取失败"),
    ROLE_STATUS_UPDATE_ERROR(5007, "角色状态更新失败"),
    ROLE_INSERT_ERROR(5008, "角色新增失败"),
    ROLE_UPDATE_ERROR(5009, "角色更新失败"),
    ROLE_DELETE_ERROR(5010, "角色删除失败"),
    ROLE_RELATE_ERROR(5011, "角色关联失败"),
    MENU_GET_ERROR(5012, "菜单权限获取失败"),
    MENU_RELATE_ERROR(5013, "菜单权限关联失败"),
    MENU_STATUS_UPDATE_ERROR(5014, "菜单状态更新失败"),
    MENU_DELETE_ERROR(5015, "菜单删除失败"),
    MENU_INSERT_ERROR(5016, "菜单新增失败"),
    MENU_UPDATE_ERROR(5017, "菜单更新失败"),
    FILE_UPLOAD_ERROR(5018, "文件上传失败"),
    AVATAR_UPDATE_ERROR(5019, "头像更新失败"),
    PROJECT_INSERT_ERROR(5020, "项目新增失败"),
    PROJECT_UPDATE_ERROR(5021, "项目更新失败"),
    PROJECT_DELETE_ERROR(5022, "项目删除失败"),
    JOB_INSERT_ERROR(5023, "作业新增失败"),
    JOB_UPDATE_ERROR(5024, "作业更新失败"),
    JOB_DELETE_ERROR(5025, "作业删除失败"),
    QUERY_ERROR(5026, "查询失败"),
    INVALID_DAG(5027, "无效的DAG"),

    // 操作相关的错误码：3开头
    INCORRECT_OPERATION(3001, "错误操作"),
    METHOD_NOT_SUPPORT(3002, "请求方式有误"),
    USER_NOT_DELETE(3003, "当前用户不能删除"),
    REQUEST_PARAM_MISSING(3004, "请求参数丢失"),
    MULTIPLE_RECORD(3005, "存在多条记录"),
    TOKEN_EXPIRE(3006, "token失效"),
    FILE_NAME_LENGTH_LIMIT(3007, "文件名超长"),
    REQUEST_PARAM_TYPE_ERROR(3008, "错误的请求参数类型"),
    REQUEST_NOT_EXISTS(3009, "请求地址不存在"),
    FILE_SIZE_LIMIT(3010, "文件过大"),
    INVALID_EXTENSION(3011, "无效的扩展类型"),

    // 其他异常
    EXCEPTION(9999, "其它异常");

    private final Integer code;

    private final String message;

    ResponseCode(int code) {
        this.code = code;
        this.message = null;
    }

    ResponseCode(int code, String message) {
        this.code = code;
        this.message = message;
    }
}

